From 593483c30d64d7f5c730700ab2e27219d1c12c55 Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 15 Jan 2016 16:01:31 +0100 Subject: [PATCH] Replace single matches by ifs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix all Clippy’s single_match warnings. --- src/cargo/sources/git/source.rs | 45 +++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index e2829ad5b..4a66b1c31 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -101,13 +101,10 @@ pub fn canonicalize_url(url: &Url) -> Url { let mut url = url.clone(); // Strip a trailing slash - match url.scheme_data { - url::SchemeData::Relative(ref mut rel) => { - if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) { - rel.path.pop(); - } + if let url::SchemeData::Relative(ref mut rel) = url.scheme_data { + if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) { + rel.path.pop(); } - _ => {} } // HACKHACK: For github URL's specifically just lowercase @@ -117,32 +114,26 @@ pub fn canonicalize_url(url: &Url) -> Url { // same case conversion rules that GitHub does. (#84) if url.domain() == Some("github.com") { url.scheme = "https".to_string(); - match url.scheme_data { - url::SchemeData::Relative(ref mut rel) => { - rel.port = Some(443); - rel.default_port = Some(443); - let path = mem::replace(&mut rel.path, Vec::new()); - rel.path = path.into_iter().map(|s| { - s.chars().flat_map(|c| c.to_lowercase()).collect() - }).collect(); - } - _ => {} + if let url::SchemeData::Relative(ref mut rel) = url.scheme_data { + rel.port = Some(443); + rel.default_port = Some(443); + let path = mem::replace(&mut rel.path, Vec::new()); + rel.path = path.into_iter().map(|s| { + s.chars().flat_map(|c| c.to_lowercase()).collect() + }).collect(); } } // Repos generally can be accessed with or w/o '.git' - match url.scheme_data { - url::SchemeData::Relative(ref mut rel) => { - let needs_chopping = { - let last = rel.path.last().map(|s| &s[..]).unwrap_or(""); - last.ends_with(".git") - }; - if needs_chopping { - let last = rel.path.pop().unwrap(); - rel.path.push(last[..last.len() - 4].to_string()) - } + if let url::SchemeData::Relative(ref mut rel) = url.scheme_data { + let needs_chopping = { + let last = rel.path.last().map(|s| &s[..]).unwrap_or(""); + last.ends_with(".git") + }; + if needs_chopping { + let last = rel.path.pop().unwrap(); + rel.path.push(last[..last.len() - 4].to_string()) } - _ => {} } url -- 2.30.2